$(function() {
  getTreeData();
});
var token = JSON.parse(localStorage.getItem("token"));
function getTreeData() {
  $.ajax({
    type : "GET",
     headers:{"JwtAuthorization":JwtAuthorizations,"Authorization":token},
    url : window.API_SERVER_URL+"/sys/category/tree/01",
    success : function(tree) {
      loadTree(tree);
    }
  });
}
function loadTree(tree) {
  $('#jstree').jstree({
    'core' : {
      'data' : tree
    },
    "plugins" : [ "search" ]
  });
  $('#jstree').jstree().open_all();
}
$('#jstree').on("changed.jstree", function(e, data) {
  if(data.node.id=='-1'){
    return;
  }
  parent.$("#extendActBusinessId").val(data.node.id);
  parent.$("#businessName").val(data.node.text);
  var index = parent.layer.getFrameIndex(window.name);  
  parent.layer.close(index);  
});
